#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;

class Node {
public:
    int val;
    Node* next;
    Node* random;

    Node(int _val) {
        val = _val;
        next = NULL;
        random = NULL;
    }
};

struct TreeNode {
       int val;
       TreeNode *left;
       TreeNode *right;
       TreeNode(int x) : val(x), left(NULL), right(NULL) {}
     };
class Solution {
public:
    Node* copyRandomList(Node* head) {
        if(head == nullptr) return nullptr;
        unordered_map<Node*,Node*> copy;
        Node *t = head;
        while (t!=nullptr){
            copy[t] = new Node(t->val);
            t = t->next;
        }
        t = head;
        while (t!= nullptr){
            copy[t]->next = t->next== nullptr?nullptr:copy[t->next];
            copy[t]->random = t->random== nullptr?nullptr:copy[t->random] ;
            t = t->next;
        }
        return copy[head];

    }
};

int main(){

}